package org.example.day20240909.app;

import org.example.day20240909.model.Account;
import org.example.day20240909.model.Department;
import org.example.day20240909.model.Employee;
import org.example.day20240909.view.AccountView;
import org.example.day20240909.view.DepartmentView;
import org.example.day20240909.view.EmployeeView;
import org.example.neusoft.util.GlobalInput;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        boolean isRunning = true;
        Scanner scanner = GlobalInput.getScanner();
        Account account = new Account();
        while (isRunning) {
            System.out.println("-----员工管理系统-----");
            if (Account.loginAccount == null) {
                System.out.println("1.用户登录");
                System.out.println("2.退出");
            } else {
                if (Account.loginAccount.getRole().equals("ADMIN")) {
                    System.out.println("1.查看个人信息");
                    System.out.println("2.员工管理");
                    System.out.println("3.部门管理");
                    System.out.println("4.注销");
                    System.out.println("5.退出");
                } else if (Account.loginAccount.getRole().equals("LEADER")) {
                    System.out.println("1.查看个人信息");
                    System.out.println("2.查看员工列表");
                    System.out.println("3.注销");
                    System.out.println("4.退出");
                } else {
                    System.out.println("1.查看个人信息");
                    System.out.println("2.注销");
                    System.out.println("3.退出");
                }
            }
            int cmd = scanner.nextInt();
            scanner.nextLine();
            switch (cmd) {
                case 1: {
                    if (Account.loginAccount != null) {
                        EmployeeView employeeView = new EmployeeView();
                        employeeView.searchEmployee(Account.loginAccount.getUser_id());//查看个人信息
                        System.out.println("按0返回上一界面:");
                        int x = scanner.nextInt();
                        if (x == 0) {
                            break;
                        }
                    } else {
                        boolean isLogin = false;
                        while (!isLogin) {
                            AccountView accountView = new AccountView();
                            System.out.println("请输入账号:");
                            account.setAccount(scanner.nextLine());
                            System.out.println("请输入密码:");
                            account.setPassword(scanner.nextLine());
                            Account.loginAccount = accountView.checkLogin(account);
                            if (Account.loginAccount != null) {
                                System.out.println("登陆成功");
                                isLogin = true;
                            } else {
                                System.out.println("登陆失败");
                            }
                        }
                    }
                    break;
                }
                case 2: {
                    if (Account.loginAccount != null && Account.loginAccount.getRole().equals("ADMIN")) {
                        //员工管理
                        boolean isManage = false;
                        while (!isManage) {
                            System.out.println("1.新增员工");
                            System.out.println("2.修改员工");
                            System.out.println("3.删除员工");
                            System.out.println("4.员工调转部门");
                            System.out.println("5.查询员工");
                            System.out.println("6.员工列表");
                            System.out.println("7.回到主页");
                            int command = scanner.nextInt();
                            scanner.nextLine();
                            switch (command) {
                                case 1: {
                                    EmployeeView employeeView = new EmployeeView();
                                    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
                                    Date date = new Date();
                                    boolean isAdding = false;
                                    while (!isAdding) {
                                        boolean isChecking = true;
                                        String employeeId = "";
                                        while (isChecking) {
                                            String today = sdf.format(date.getTime());
                                            Random random = new Random();
                                            int randomId = random.nextInt(99999);
                                            StringBuffer creatEmployeeId = new StringBuffer(today);
                                            creatEmployeeId.append(randomId);
                                            if (!employeeView.checkEmployeeId(String.valueOf(creatEmployeeId))) {
                                                employeeId = String.valueOf(creatEmployeeId);
                                                isChecking = false;
                                            }
                                        }
                                        Employee employee = new Employee();
                                        DepartmentView departmentView = new DepartmentView();
                                        System.out.println("员工编号:" + employeeId);
                                        employee.setEmployee_id(employeeId);
                                        System.out.println("请输入员工姓名:");
                                        employee.setEmployee_name(scanner.nextLine());
                                        boolean isEmail = true;
                                        while (isEmail) {
                                            System.out.println("请输入员工邮箱:");
                                            String inputEmail = scanner.nextLine();
                                            if (!employeeView.checkEmployeeEmail(inputEmail)) {
                                                isEmail = false;
                                                employee.setEmployee_email(inputEmail);
                                            } else {
                                                System.out.println("邮箱重复！！！");
                                            }
                                        }
                                        System.out.println("请输入员工生日(yyyy-MM-dd):");
                                        employee.setBirthday(scanner.nextLine());
                                        System.out.println("请输入员工参加工作日期(yyyy-MM-dd):");
                                        employee.setHire_date(scanner.nextLine());
                                        System.out.println("请输入员工入司日期(yyyy-MM-dd):");
                                        employee.setJoin_date(scanner.nextLine());
                                        boolean isGender = true;
                                        while (isGender) {
                                            System.out.println("请选择员工性别(1-男  2-女):");
                                            int gender = scanner.nextInt();
                                            if (gender == 1) {
                                                employee.setGender("男");
                                                isGender = false;
                                            } else if (gender == 2) {
                                                employee.setGender("女");
                                                isGender = false;
                                            } else {
                                                System.out.println("输入数据不合法！(1-男  2-女)");
                                            }
                                        }
                                        boolean isDepartment = true;
                                        while (isDepartment) {
                                            System.out.println("请输入部门编号:");
                                            scanner.nextLine();
                                            String inputDepartment = scanner.nextLine();
                                            Department department = departmentView
                                                    .findEmployeeDepartment(inputDepartment);
                                            if (department == null) {
                                                System.out.println("部门编号不存在！");
                                            } else {
                                                employee.setDepartment_name(department.getDepartment_name());
                                                isDepartment = false;
                                            }
                                        }
                                        employeeView.addEmployee(employee);
                                        System.out.println("是否继续新增员工，输入(Y/N):");
                                        String nextCommand = scanner.nextLine();
                                        if (nextCommand.equals("N")) {
                                            isAdding = true;
                                        } else if (nextCommand.equals("Y") || nextCommand.equals("y")) {
                                            isAdding = false;
                                        } else {
                                            isManage = true;
                                            break;
                                        }
                                    }
                                }
                                break;
                                case 2: {
                                    boolean isUpdateing = true;
                                    while (isUpdateing) {
                                        System.out.println("请输入需要查询的员工编号:");
                                        String inputId = scanner.nextLine();
                                        EmployeeView employeeView = new EmployeeView();
                                        if (employeeView.checkEmployeeId(inputId)) {
                                            Employee employee = employeeView.getEmployee(inputId);
                                            System.out.println("是否修改员工数据(Y/N):");
                                            String updateCommand = scanner.nextLine();
                                            if (updateCommand.equals("Y") || updateCommand.equals("y")) {
                                                System.out.println("修改数据时如需使用旧值不用输入，直接回车");
                                                System.out.println("请输入员工姓名:");
                                                String inputName = scanner.nextLine();
                                                String getOldName = employee.getEmployee_name();
                                                employee.setEmployee_name(inputName.equals("")
                                                        ? getOldName : inputName);
                                                boolean isEmail = true;
                                                while (isEmail) {
                                                    System.out.println("请输入员工邮箱:");
                                                    String inputEmail = scanner.nextLine();
                                                    if (!inputEmail.equals("")) {
                                                        if (!employeeView.checkEmployeeEmail(inputEmail)) {
                                                            isEmail = false;
                                                            employee.setEmployee_email(inputEmail);
                                                        } else {
                                                            System.out.println("邮箱重复！！！");
                                                        }
                                                    } else {
                                                        isEmail = false;
                                                    }
                                                }
                                                System.out.println("请输入员工生日(yyyy-MM-dd):");
                                                String inputBirthday = scanner.nextLine();
                                                String getOldBirthday = employee.getBirthday();
                                                employee.setBirthday(inputBirthday.equals("")
                                                        ? getOldBirthday : inputBirthday);
                                                System.out.println("请输入员工参加工作日期(yyyy-MM-dd):");
                                                String inputHireDate = scanner.nextLine();
                                                String getOldHireDate = employee.getHire_date();
                                                employee.setHire_date(inputHireDate.equals("")
                                                        ? getOldHireDate : inputHireDate);
                                                System.out.println("请输入员工入司日期(yyyy-MM-dd):");
                                                String inputJoinDate = scanner.nextLine();
                                                String getOldJoinDate = employee.getHire_date();
                                                employee.setJoin_date(inputJoinDate.equals("")
                                                        ? getOldJoinDate : inputJoinDate);
                                                boolean isGender = true;
                                                while (isGender) {
                                                    System.out.println("请选择员工性别(1-男  2-女):");
                                                    String gender = scanner.nextLine();
                                                    if (!gender.equals("")) {
                                                        if (gender.equals("1")) {
                                                            employee.setGender("男");
                                                            isGender = false;
                                                        } else if (gender.equals("2")) {
                                                            employee.setGender("女");
                                                            isGender = false;
                                                        } else {
                                                            System.out.println("输入数据不合法！(1-男  2-女)");
                                                        }
                                                    } else {
                                                        isGender = false;
                                                    }
                                                }
                                                boolean isDepartment = true;
                                                while (isDepartment) {
                                                    System.out.println("请输入部门编号:");
                                                    String inputDepartment = scanner.nextLine();
                                                    if (!inputDepartment.equals("")) {
                                                        DepartmentView departmentView = new DepartmentView();
                                                        Department department = departmentView
                                                                .findEmployeeDepartment(inputDepartment);
                                                        if (department == null) {
                                                            System.out.println("部门编号不存在！");
                                                        } else {
                                                            employee.setDepartment_name(department
                                                                    .getDepartment_name());
                                                            isDepartment = false;
                                                        }
                                                    } else {
                                                        isDepartment = false;
                                                    }
                                                }
                                                employeeView.updateEmployee(employee);
                                                System.out.println("是否继续修改员工，输入(Y/N):");
                                                String nextCommand = scanner.nextLine();
                                                if (nextCommand.equals("N")) {
                                                    isUpdateing = false;
                                                } else if (nextCommand.equals("Y") || nextCommand.equals("y")) {
                                                    isUpdateing = true;
                                                } else {
                                                    isManage = true;
                                                    break;
                                                }
                                            } else {
                                                break;
                                            }
                                        } else {
                                            System.out.println("员工编号不存在！");
                                        }
                                    }
                                    break;
                                }
                                case 3: {
                                    boolean isChecking = true;
                                    EmployeeView employeeView = new EmployeeView();
                                    while (isChecking) {
                                        System.out.println("请输入需要删除的员工编号:");
                                        String inputId = scanner.nextLine();
                                        if (employeeView.checkEmployeeId(inputId)) {
                                            employeeView.searchEmployee(inputId);
                                            System.out.println("是否删除员工数据(Y/N):");
                                            String deleteCommand = scanner.nextLine();
                                            if (deleteCommand.equals("Y") || deleteCommand.equals("y")) {
                                                employeeView.deleteEmployee(inputId);
                                                System.out.println("删除员工成功");
                                                isChecking = false;
                                            } else {
                                                break;
                                            }
                                        } else {
                                            System.out.println("员工编号不存在！");
                                        }
                                    }
                                    break;
                                }
                                case 4: {
                                    boolean isTurning = true;
                                    while (isTurning) {
                                        System.out.println("请输入需要查询的员工编号:");
                                        String inputId = scanner.nextLine();
                                        EmployeeView employeeView = new EmployeeView();
                                        if (employeeView.checkEmployeeId(inputId)) {
                                            Employee employee = employeeView.checkDepartmentEmployeeId(inputId);
                                            System.out.println("是否进行员工部门调转 (Y/N):");
                                            String turnCommand = scanner.nextLine();
                                            if (turnCommand.equals("Y") || turnCommand.equals("y")) {
                                                DepartmentView departmentView = new DepartmentView();
                                                boolean isDepartment = true;
                                                while (isDepartment) {
                                                    System.out.println("请输入部门编号:");
                                                    String inputDepartment = scanner.nextLine();
                                                    Department department = departmentView
                                                            .findEmployeeDepartment(inputDepartment);
                                                    if (department == null) {
                                                        System.out.println("部门编号不存在！");
                                                    } else if (department.getEmployee_num() + 1
                                                            > department.getDepartment_quota()) {
                                                        System.out.println("部门编制已满！");
                                                    } else if (employee.getDepartment_name()
                                                            .equals(department.getDepartment_name())) {
                                                        System.out.println("员工当前部门没有变化");
                                                    } else {
                                                        String oldDepartment_name = employee.getDepartment_name();
                                                        employee.setDepartment_name(department.getDepartment_name());
                                                        employeeView.turnEmployee(employee, oldDepartment_name
                                                                , department.getDepartment_id());
                                                        isDepartment = false;
                                                    }
                                                }
                                                System.out.println("员工部门调转成功");
                                                isTurning = false;
                                            } else {
                                                break;
                                            }
                                        } else {
                                            System.out.println("员工编号不存在！");
                                        }
                                    }
                                    break;
                                }
                                case 5: {
                                    boolean isChecking = true;
                                    while (isChecking) {
                                        System.out.println("请输入需要查询的员工编号:");
                                        String inputId = scanner.nextLine();
                                        EmployeeView employeeView = new EmployeeView();
                                        if (employeeView.checkEmployeeId(inputId)) {
                                            employeeView.searchEmployee(inputId);
                                            System.out.println("输入任意值返回上级菜单:");
                                            if (scanner.nextLine() != null) {
                                                isChecking = false;
                                            }
                                        } else {
                                            System.out.println("员工编号不存在！");
                                        }
                                    }
                                    break;
                                }
                                case 6: {
                                    EmployeeView employeeView = new EmployeeView();
                                    employeeView.checkEmployeeList();
                                    System.out.println("输入任意值返回上级菜单:");
                                    scanner.nextLine();
                                    break;
                                }
                                case 7: {
                                    isManage = true;
                                    break;
                                }
                            }
                        }
                    } else if (Account.loginAccount != null && Account.loginAccount.getRole().equals("LEADER")) {
                        //部长查看员工列表
                        EmployeeView employeeView = new EmployeeView();
                        employeeView.checkEmployeeHeadDepartment();
                        System.out.println("输入任意值返回上级菜单:");
                        scanner.nextLine();
                        break;
                    } else if (Account.loginAccount != null){
                        Account.loginAccount = null;
                        System.out.println("注销成功");
                        break;
                    }else {
                        isRunning = false;
                        System.out.println("byebye");
                    }
                    break;
                }
                case 3: {
                    if (Account.loginAccount != null && Account.loginAccount.getRole().equals("ADMIN")) {
                        //部门管理
                        boolean isManage = false;
                        while (!isManage) {
                            System.out.println("1.新增部门");
                            System.out.println("2.修改部门");
                            System.out.println("3.删除部门");
                            System.out.println("4.查看部门员工");
                            System.out.println("5.查询部门");
                            System.out.println("6.部门列表");
                            System.out.println("7.回到主页");
                            int command = scanner.nextInt();
                            scanner.nextLine();
                            switch (command) {
                                case 1: {
                                    boolean isAdding = false;
                                    while (!isAdding) {
                                        boolean isChecking = true;
                                        System.out.println("请输入部门编号:");
                                        String inputDepartmentId = scanner.nextLine();
                                        DepartmentView departmentView = new DepartmentView();
                                        Department department = new Department();
                                        while (isChecking) {
                                            if (inputDepartmentId.equals("")) {
                                                System.out.println("部门编号不可为空！");
                                                isChecking = false;
                                            }
                                            if (departmentView.checkDepartmentId(inputDepartmentId)) {
                                                System.out.println("重复的部门编号！请重新输入！");
                                                isChecking = false;
                                            } else {
                                                department.setDepartment_id(inputDepartmentId);
                                                isChecking = false;
                                            }
                                        }
                                        System.out.println("请输入部门名称:");
                                        String inputDepartmentName = scanner.nextLine();
                                        department.setDepartment_name(inputDepartmentName);

                                        boolean isQuota = true;
                                        while (isQuota) {
                                            System.out.println("请输入部门编制:");
                                            double inputDepartmentQuota = scanner.nextDouble();
                                            if (inputDepartmentQuota > 0) {
                                                department.setDepartment_quota(inputDepartmentQuota);
                                                isQuota = false;
                                            }
                                        }
                                        boolean isDate = true;
                                        while (isDate) {
                                            try {
                                                System.out.println("请输入部门建立日期(YYYY-MM-DD):");
                                                scanner.nextLine();
                                                String inputDate = scanner.nextLine();
                                                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                                                Date date = sdf.parse(inputDate);
                                                department.setEstablishment_date(inputDate);
                                                isDate = false;
                                            } catch (Exception e) {
                                                System.out.println("输入时间格式错误");
                                            }
                                        }
                                        boolean isHeader = true;
                                        while (isHeader) {
                                            System.out.println("请输入部长的员工编号:");
                                            String inputDepartmentHeadId = scanner.nextLine();
                                            EmployeeView employeeView = new EmployeeView();
                                            if (employeeView.checkEmployeeId(inputDepartmentHeadId)) {
                                                department.setDepartment_head_name(employeeView
                                                        .getEmployeeInJob(inputDepartmentHeadId).getEmployee_name());
                                                isHeader = false;
                                            } else {
                                                System.out.println("员工编号不存在！");
                                            }
                                        }
                                        boolean isSuperior = true;
                                        while (isSuperior) {
                                            System.out.println("请输入上级部门编号:");
                                            String inputSuperiorId = scanner.nextLine();
                                            if (departmentView.checkDepartmentId(inputSuperiorId)) {
                                                department.setSuperior_department_name(departmentView
                                                        .findEmployeeDepartment(inputSuperiorId).getDepartment_name());
                                                isSuperior = false;
                                            } else {
                                                System.out.println("上级部门编号不存在！");
                                            }
                                        }
                                        departmentView.addDepartment(department);
                                        System.out.println("是否继续新增部门，输入(Y/N):");
                                        String nextCommand = scanner.nextLine();
                                        if (nextCommand.equals("N")) {
                                            isAdding = true;
                                        } else if (nextCommand.equals("Y") || nextCommand.equals("y")) {
                                            isAdding = false;
                                        } else {
                                            isManage = true;
                                            break;
                                        }
                                    }
                                    break;
                                }
                                case 2: {
                                    boolean isUpdateing = true;
                                    while (isUpdateing) {
                                        boolean isChecking = true;
                                        System.out.println("请输入部门编号:");
                                        String inputDepartmentId = scanner.nextLine();
                                        DepartmentView departmentView = new DepartmentView();
                                        Department department = new Department();
                                        while (isChecking) {
                                            if (inputDepartmentId.equals("")) {
                                                System.out.println("部门编号不可为空！");
                                                isChecking = false;
                                            } else {
                                                department = departmentView.findEmployeeDepartment(inputDepartmentId);
                                                isChecking = false;
                                            }
                                        }
                                        departmentView.displayEmployeeDepartment(inputDepartmentId);
                                        System.out.println("是否修改部门数据(Y/N):");
                                        String updateCommand = scanner.nextLine();
                                        if (updateCommand.equals("Y") || updateCommand.equals("y")) {
                                            System.out.println("修改数据时如需使用旧值不用输入，直接回车");
                                            System.out.println("请输入部门名称:");
                                            String inputDepartmentName = scanner.nextLine();
                                            String oldDepartmentName = department.getDepartment_name();
                                            boolean isSameDepartmentName = false;
                                            if (inputDepartmentName.equals("")) {
                                                isSameDepartmentName = true;
                                            }
                                            department.setDepartment_name(inputDepartmentName.equals("")
                                                    ? oldDepartmentName : inputDepartmentName);
                                            boolean isQuota = true;
                                            while (isQuota) {
                                                System.out.println("请输入部门编制:");
                                                String inputDepartmentQuota = scanner.nextLine();
                                                if (inputDepartmentQuota.equals("")) {
                                                    break;
                                                }
                                                if (Double.parseDouble(inputDepartmentQuota) > 0) {
                                                    department.setDepartment_quota(Double
                                                            .parseDouble(inputDepartmentQuota));
                                                    isQuota = false;
                                                } else {
                                                    isQuota = false;
                                                }
                                            }
                                            boolean isDate = true;
                                            while (isDate) {
                                                try {
                                                    System.out.println("请输入部门建立日期(YYYY-MM-DD):");
                                                    String inputDate = scanner.nextLine();
                                                    if (inputDate.equals("")) {
                                                        break;
                                                    }
                                                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                                                    Date date = sdf.parse(inputDate);
                                                    department.setEstablishment_date(inputDate);
                                                    isDate = false;
                                                } catch (Exception e) {
                                                    System.out.println("输入时间格式错误");
                                                }
                                            }
                                            boolean isHeader = true;
                                            while (isHeader) {
                                                System.out.println("请输入部长的员工编号:");
                                                String inputDepartmentHeadId = scanner.nextLine();
                                                if (inputDepartmentHeadId.equals("")) {
                                                    break;
                                                }
                                                EmployeeView employeeView = new EmployeeView();
                                                if (employeeView.checkEmployeeId(inputDepartmentHeadId)) {
                                                    department.setDepartment_head_name(employeeView
                                                            .getEmployeeInJob(inputDepartmentHeadId)
                                                            .getEmployee_name());
                                                    isHeader = false;
                                                } else {
                                                    System.out.println("员工编号不存在！");
                                                }
                                            }
                                            boolean isSuperior = true;
                                            while (isSuperior) {
                                                System.out.println("请输入上级部门编号:");
                                                String inputSuperiorId = scanner.nextLine();
                                                if (inputSuperiorId.equals("")) {
                                                    break;
                                                }
                                                if (departmentView.checkDepartmentId(inputSuperiorId)) {
                                                    department.setSuperior_department_name(departmentView
                                                            .findEmployeeDepartment(inputSuperiorId)
                                                            .getDepartment_name());
                                                    isSuperior = false;
                                                } else {
                                                    System.out.println("上级部门编号不存在！");
                                                }
                                            }
                                            if (isSameDepartmentName) {
                                                departmentView.updateSameNameDepartment(department);
                                            } else {
                                                departmentView.updateDepartment(department);
                                            }
                                            System.out.println("是否继续修改部门，输入(Y/N):");
                                            String nextCommand = scanner.nextLine();
                                            if (nextCommand.equals("Y") || nextCommand.equals("y")) {
                                                isUpdateing = true;
                                            } else {
                                                isManage = true;
                                                break;
                                            }
                                        } else {
                                            isUpdateing = false;
                                        }
                                    }
                                    break;
                                }
                                case 3: {
                                    DepartmentView departmentView = new DepartmentView();
                                    boolean isChecking = true;
                                    while (isChecking) {
                                        System.out.println("请输入需要删除的部门编号:");
                                        String inputId = scanner.nextLine();
                                        if (departmentView.checkDepartmentId(inputId)) {
                                            departmentView.displayEmployeeDepartment(inputId);
                                            Department department = departmentView.findEmployeeDepartment(inputId);
                                            System.out.println("是否继续删除部门，输入(Y/N):");
                                            String nextCommand = scanner.nextLine();
                                            if (nextCommand.equals("Y") || nextCommand.equals("y")
                                                    && department.getEmployee_num() == 0) {
                                                departmentView.deleteDepartment(inputId);
                                                System.out.println("删除成功");
                                                System.out.println("输入任意值返回上级菜单:");
                                                scanner.nextLine();
                                                isChecking = false;
                                            } else {
                                                isChecking = false;
                                            }
                                        } else {
                                            System.out.println("部门编号不存在！");
                                        }
                                    }
                                    break;
                                }
                                case 4: {
                                    DepartmentView departmentView = new DepartmentView();
                                    boolean isChecking = true;
                                    while (isChecking) {
                                        System.out.println("请输入需要查询的部门编号:");
                                        String inputId = scanner.nextLine();
                                        if (departmentView.checkDepartmentId(inputId)) {
                                            departmentView.displayDepartmentEmployee(inputId);
                                            System.out.println("输入任意值返回上级菜单");
                                            scanner.nextLine();
                                            isChecking = false;
                                        } else {
                                            System.out.println("部门编号不存在！");
                                        }
                                    }
                                    break;
                                }
                                case 5: {
                                    DepartmentView departmentView = new DepartmentView();
                                    boolean isChecking = true;
                                    while (isChecking) {
                                        System.out.println("请输入需要查询的部门编号:");
                                        String inputId = scanner.nextLine();
                                        if (departmentView.checkDepartmentId(inputId)) {
                                            departmentView.displayDepartment(inputId);
                                            System.out.println("输入任意值返回上级菜单");
                                            scanner.nextLine();
                                            isChecking = false;
                                        } else {
                                            System.out.println("部门编号不存在！");
                                        }
                                    }
                                    break;
                                }
                                case 6: {
                                    boolean isChecking = true;
                                    while (isChecking) {
                                        DepartmentView departmentView = new DepartmentView();
                                        departmentView.displayAllDepartment();
                                        System.out.println("输入任意值返回上级菜单");
                                        scanner.nextLine();
                                        isChecking = false;
                                    }
                                    break;
                                }
                                case 7: {
                                    isManage = true;
                                    break;
                                }
                            }
                        }
                        break;
                    } else if (Account.loginAccount != null && Account.loginAccount.getRole().equals("LEADER")) {
                        Account.loginAccount = null;
                        System.out.println("注销成功");
                        break;
                    } else {
                        isRunning = false;
                        System.out.println("byebye");
                    }
                }
                case 4: {
                    if (Account.loginAccount != null && Account.loginAccount.getRole().equals("ADMIN")) {
                        Account.loginAccount = null;
                        System.out.println("注销成功");
                    } else if (Account.loginAccount != null && Account.loginAccount.getRole().equals("LEADER")) {
                        isRunning = false;
                        System.out.println("byebye");
                    }
                    break;
                }
                case 5: {
                    if (Account.loginAccount != null && Account.loginAccount.getRole().equals("ADMIN")) {
                        isRunning = false;
                        System.out.println("byebye");
                        break;
                    }
                }
                default: {
                    break;
                }
            }
        }
    }
}
